Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Passing a temp-table parameter by binding
Starting with OpenEdge Release 10.1A, you can also save the overhead of copying a temp-table’s definition and data on a local call by using the
BINDkeyword. You use this keyword in both the calling and called routines to tell Progress to bind both temp-table references to the same temp-table instance. In the calling routine, you add the keyword to the parameter in theRUNstatement, instead of theBY-REFERENCEkeyword:
In the called routine, you specify the keyword as part of the parameter definition:
The most basic case where you would want to use the
BINDkeyword is when you want to use the called routine’s temp-table instance instead of the calling routine’s instance. For example, you may have a routine in your application that has a cache of useful data, such as all Item values for use in entering an Order, which it has retrieved from the database and stored in a temp-table. Other routines running in the same session might want access to this data, for example to display the list of Items in a selection list. To save the overhead of copying the temp-table to all the other routines that want to share its data, you can bind the callers to the called routine’s temp-table cache.
![]()
To pass a temp-table by binding from the called routine to the calling routine:
- In the calling routine, define the temp-table as
REFERENCE-ONLY. This tells Progress not to instantiate the caller’s temp-table when the routine is first run.- In the calling routine, specify the
BINDkeyword in theRUNstatement that uses the temp-table parameter. This tells Progress to bind both ends of the call to the same temp-table instance.- In the called routine, define the temp-table parameter with the
BINDkeyword. This confirms to Progress that both ends of the call are to refer to the same instance. You must always specifyBINDon both ends of the call.- Define the temp-table parameters in both routines as
OUTPUT. This tells Progress to use the called routine’s temp-table instance and change all references within the caller to point to it.
![]()
To pass a temp-table by binding from the calling routine to the called routine:
- In the called routine, define the temp-table as
REFERENCE-ONLY.- In the called routine, define the temp-table parameter with the
BINDkeyword.- In the calling routine, specify the
BINDkeyword in theRUNstatement that uses the temp-table parameter.- Make sure that the parameter mode matches in both routines. That is, they must both be defined as
INPUT-OUTPUTor both be defined asINPUTparameters.You can use the
BINDsyntax to change the scope of the temp-table that is passed from caller to called routine. When you useBY-REFERENCEin an internal procedure call, as was described earlier, the scope of the temp-table is limited to that one call. That is, Progress changes the temp-table references (within the internal procedure you run) to refer back to the caller. When the internal procedure completes and returns to the caller, the association ends. In some exceptional cases, you might want to bind the caller’s temp-table to the called routine for their mutual lifetime.Table 11–1 describes how to decide between passing a temp-table as a parameter using the
BY-REFERENCEkeyword versus usingBIND. This table refers only to those calls that always or sometimes occur between routines in the same session. If you know that the call will always be to routines in different sessions, you should just pass the temp-table parameter by value.
1The temp-table parameter must be anOUTPUTparameter for the first call involving the temp-table so that the calling routine’sREFERENCE-ONLYtable can point to a valid instantiated table. In subsequent calls, the parameter can be passed asINPUT.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |